//
//  TPassengerListCell.m
//  LoveShare
//
//  Created by ways on 2017/4/27.
//  Copyright © 2017年 tikeyc. All rights reserved.
//

#import "TPassengerListCell.h"
#import "SPKitExample.h"

@interface TPassengerListCell ()
- (IBAction)callPhoneButtonAction:(UIButton *)sender;

- (IBAction)sendIMButtonAction:(UIButton *)sender;


@end

@implementation TPassengerListCell


+ (instancetype)loadFromNib {
    TPassengerListCell *cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:NULL] lastObject];
    return cell;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self setupAutoHeightWithBottomView:_messageLabel bottomMargin:10];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - set

- (void)setFindPassengerModel:(TFindPassengerModel *)findPassengerModel {
    _findPassengerModel = findPassengerModel;
    
    [self refreshUI];
}


- (void)refreshUI {
    self.startToEndLabel.text = [[_findPassengerModel.startPlace stringByAppendingString:@" ——> "] stringByAppendingString:_findPassengerModel.destination];
    
    self.passengerLabel.text = [@"乘客数量: " stringByAppendingString:_findPassengerModel.passenger];
    
    self.goTimeLabel.text = [@"出发时间: " stringByAppendingString:_findPassengerModel.goTime];
    
    self.messageLabel.text = [@"备注: " stringByAppendingString:_findPassengerModel.message];
}


#pragma mark -

- (IBAction)callPhoneButtonAction:(UIButton *)sender {
    if (_findPassengerModel.contactMobile) {
        [TKCAppTools userTelephoningNum:_findPassengerModel.contactMobile type:TKCTelephoningTypeApplicationWebView];
    }

}

- (IBAction)sendIMButtonAction:(UIButton *)sender {
    YWPerson *person = [[YWPerson alloc] initWithPersonId:@"visitor861"];
    [[SPKitExample sharedInstance] exampleOpenConversationViewControllerWithPerson:person fromNavigationController:self.viewController.navigationController];
}
@end
